<!--  -->
<template>
  <div class="app-container">
    <el-form :inline="true" size="small">
      <el-form-item label="模板编号">
        <el-input
          v-model="kwd1"
          placeholder="请输入分类编号"
          size="small"
        ></el-input>
      </el-form-item>
      <el-form-item label="模板名称">
        <el-input
          v-model="kwd2"
          placeholder="请输入分类名称"
          size="small"
        ></el-input>
      </el-form-item>

      <el-button
        icon="el-icon-search"
        type="primary"
        size="small"
        @click="search"
        >搜索</el-button
      >
      <el-button icon="el-icon-refresh" size="small" @click="restart"
        >重置</el-button
      >
      <el-button icon="el-icon-edit" type="warning" size="small" @click="add"
        >新增</el-button
      >
      <el-button
        icon="el-icon-delete"
        type="danger"
        size="small"
        @click="muDelete"
        >删除</el-button
      >
    </el-form>
    <el-table :data="tableData" border stripe>
      <el-table-column
        type="selection"
        width="60"
        align="center"
      ></el-table-column>

      <template v-for="(i, index) in columns">
        <el-table-column
          v-if="index == 5"
          :key="i.id"
          :label="i.label"
          align="center"
          :width="i.width"
        >
          <template slot-scope="scope">
            <div class="status">
              {{ scope.row.status }}
            </div>
          </template>
        </el-table-column>

        <el-table-column
          v-else
          :prop="i.data"
          :key="i.id"
          :label="i.label"
          align="center"
          :width="i.width"
        />
      </template>
      <el-table-column align="center" label="操作" width="220">
        <template slot-scope="scope">
          <el-button
            type="text"
            icon="el-icon-search"
            @click="detail(scope.row)"
            >查看</el-button
          >
          <el-button
            :disabled="scope.row.status == '已审批'"
            type="text"
            icon="el-icon-stopwatch"
            @click="check(scope.row)"
            >审批</el-button
          >
          <el-button
            type="text"
            icon="el-icon-delete"
            style="color: #f66"
            @click="del(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <div class="page">
      <el-pagination
        @size-change="sizeChange"
        @current-change="currentChange"
        :current-page.sync="page"
        :page-sizes="[20, 40, 80, 100]"
        :page-size="limit"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        background
      ></el-pagination>
    </div>

    <!-- 查看 -->
    <el-dialog
      title="查看"
      :visible.sync="showDialog"
      width="40%"
      @close="showDialog = false"
    >
      <div class="dBox">
        <div class="dList">
          <div class="dLabel">社群编号</div>
          <div class="dCon">{{ tableData[i].id }}</div>
        </div>
        <div class="dList">
          <div class="dLabel">社群名称</div>
          <div class="dCon">{{ tableData[i].name }}</div>
        </div>
        <div class="dList">
          <div class="dLabel">社群群主</div>
          <div class="dCon">{{ tableData[i].name }}</div>
        </div>
        <div class="dList">
          <div class="dLabel">群员数量</div>
          <div class="dCon">{{ tableData[i].member }}</div>
        </div>
        <div class="dList">
          <div class="dLabel">订单数量</div>
          <div class="dCon">{{ tableData[i].count }}</div>
        </div>
         <div class="dList">
          <div class="dLabel">累计佣金金额</div>
          <div class="dCon">{{ tableData[i].total }}</div>
        </div>
      </div>
      <span slot="footer">
        <el-button @click="showDialog = false">取消</el-button>
        <el-button type="primary" @click>确定</el-button>
      </span>
    </el-dialog>

    <!-- 审批 -->
    <el-dialog
      title="审批"
      :visible.sync="showCheck"
      width="40%"
      @close="showCheck = false"
    >
      <div class="dBox">
        <div class="dList">
          <div class="dLabel">社群编号</div>
          <div class="dCon">{{ tableData[i].id }}</div>
        </div>
        <div class="dList">
          <div class="dLabel">社群名称</div>
          <div class="dCon">{{ tableData[i].name }}</div>
        </div>
        <div class="dList">
          <div class="dLabel">申请人</div>
          <div class="dCon">{{ tableData[i].name }}</div>
        </div>
        <div class="dList">
          <div class="dLabel">申请时间</div>
          <div class="dCon">{{ tableData[i].time }}</div>
        </div>
        <div class="dList">
          <div class="dLabel">申请人身份</div>
          <div class="dCon">{{ tableData[i].indentity }}</div>
        </div>
      </div>
      <span slot="footer">
        <el-button @click="showCheck = false">取消</el-button>
        <el-button type="primary" @click>确认审批</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "slider",
  data() {
    return {
      kwd1: "",
      kwd2: "",
      keyword: "",
      i:0,
      page: 1,
      limit: 10,
      total: 10,
      dialogTitle: "创建",
      showDialog: false,
      showCheck: false,
      form: {},
      tableData: [
        {
          id: "1",
          name: "社群名称",
          member: "210",
          count: "11",
          total: "40",
          status: "已审批",
          time: "2021-03-23 12:22:22",
          indentity: "会员",
        },
        {
          id: "2",
          name: "社群名称",
          member: "230",
          count: "13",
          total: "40",
          status: "未审批",
          time: "2021-03-23 12:22:22",
          indentity: "会员",
        },
        {
          id: "3",
          name: "社群名称",
          member: "120",
          count: "41",
          total: "40",
          status: "已审批",
          time: "2021-03-23 12:22:22",
          indentity: "会员",
        },
      ],

      columns: [
        { key: 0, label: `社群编号`, data: "id", visible: true, width: "80" },
        { key: 1, label: `社群名称`, data: "name", visible: true },
        { key: 2, label: `群员数量`, data: "member", visible: true },
        { key: 3, label: `订单数量`, data: "count", visible: true },
        { key: 3, label: `累计佣金金额`, data: "total", visible: true },
        { key: 4, label: `社群状态`, data: "status", visible: true },
      ],
    };
  },
  created() {},
  methods: {
    search() {},
    add() {
      this.form = {};
      this.showDialog = true;
    },
    detail(i) {
      this.showDialog = true;
    },

    restart() {
      this.kwd1 = "";
      this.kwd2 = "";
    },
    check() {
      this.showCheck = true;
    },
    del(i, d) {
      this.$confirm("确认删除所选数据？", "确认删除", {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.tableData.splice(i, 1);
        })
        .catch(() => {});
    },
    muDelete() {},
    sizeChange() {},
    currentChange() {},
  },
};
</script>
<style scoped>
.slideImg {
  width: 140px;
}
.status {
  border: 1px solid #333;
  color: #333;
  width: 80px;
  margin: 0 auto;
  border-radius: 20px;
}


</style>
